package excutor;

import java.util.concurrent.Executor;
import java.util.concurrent.Executors;

public class Main {

	public static void main(String[] args) {
		testExecutorsThreadPool();
	}
	
	public static void testExecutorsThreadPool() {
		Executor executor = Executors.newFixedThreadPool(3);
		for(int i=0;i<10000;i++) {
			int tmp = i;
			executor.execute(new Runnable() {
				@Override
				public void run() {
					System.out.println(String.format("%s-start-%s", Thread.currentThread().getName(),tmp));
					try {
						Thread.sleep(5000);
					} catch (InterruptedException e) {
						e.printStackTrace();
					}
					System.out.println(String.format("%s-end-%s", Thread.currentThread().getName(),tmp));
				}
			});
		}
	}
	
}
